/// <reference path="../types.ts" />
/// <reference path="../helpers.ts" />
/// <reference path="organization.ts" />

module $Xrm.Messages {
    export class CreateRequest extends OrganizationRequest {
        public Target: $Xrm.Entity = null;

        constructor() {
            super("Create");
        }

        GetResponse(responseXml: Document): CreateResponse {
            return new CreateResponse(responseXml);
        }

        ToSoapXml(): string {
            this.Parameters["Target"] = this.Target;

            return super.ToSoapXml();
        }
    }

    export class CreateResponse extends OrganizationResponse {
        public Id: string;

        constructor(responseXml?: Document) {
            super("Create", responseXml);

            this.BindProperties();
        }

        BindProperties(): void {
            super.BindProperties();

            this.Id = this.Results["id"]; // interesting that this parameter is lowercase...
        }
    }
}